﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


    class GeneratesAllTheVariations
    {   
    
        static void Main()
        {
            int length = int.Parse(Console.ReadLine());
            int[] array = new int[length];

            for (int i = 0; i < length; i++)
            {
                array[i] = i + 1;
            }

            int[] elements = new int[length];
            int k = int.Parse(Console.ReadLine());

            combinations(array, elements, k, k);
        }

        static public void combinations(int[] array, int[] elements, int max, int k)
        {
           if(k == 0)
           {
                Console.Write("{ ");
                for (int j = 0; j < max; j++)
                {
                    Console.Write("{0} ", elements[j]);
                }
                Console.Write("}");
                Console.WriteLine("");
                return;
            }

           for (int i = 0; i < array.Length; i++)
           {
               elements[max - k] = array[i];
               combinations(array, elements, max, k - 1);
           }
        }
        
    }